<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateRegistriesTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('registries', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->bigInteger('agent_id')->index()->comment('代理商ID');
            $table->bigInteger('user_id')->index()->comment('用户ID');

            # 作品信息
            $table->string('product_name', 64)->comment('作品名称');
            $table->string('product_create_nat', 16)->comment('作品创作性质');
            $table->integer('word_count')->nullable()->comment('文字类作品字数');
            $table->string('video_length', 32)->nullable()->comment('视频类作品长度');
            $table->string('product_cat', 16)->comment('作品类别');
            $table->date('product_create_date')->comment('创作完成日期');
            $table->string('product_create_address', 64)->comment('创作完成地点');
            $table->boolean('is_pub')->comment('是否已发表');
            $table->date('product_pub_date')->nullable()->comment('发表日期');
            $table->string('product_pub_address', 64)->nullable()->comment('发表地点');
            $table->string('create_intention', 1024)->nullable()->comment('作品创作意图');

            # 权属信息
            $table->string('apply_method', 16)->comment('申请方式');
            $table->string('accept_method', 16)->comment('权利获取方式');
            $table->string('accept_method_explain', 64)->nullable()->comment('权利获取方式说明');
            $table->string('belong_method', 16)->comment('权利归属方式');
            $table->string('belong_method_explain', 512)->nullable()->comment('权利归属方式说明');
            $table->string('hold_names', 256)->comment('权利拥有状况');
            $table->string('hold_names_explain', 512)->nullable()->comment('权利拥有状况说明');
            $table->string('originality', 1024)->nullable()->comment('作品独创性说明');
            $table->string('signature', 32)->nullable()->comment('作品署名');

            # 支付信息
            $table->string('settle_way', 16)->comment('结算方式');
            $table->integer('pay_amount')->nullable()->comment('支付金额');

            # 登记和证书信息
            $table->string('register_id', 32)->default('')->index()->comment('注册ID,提交成功后返回');
            $table->string('cert_file_url', 256)->nullable()->comment('证书文件地址');
            $table->string('cert_image_urls', 1024)->nullable()->comment('证书图片地址，多张图片使用,分隔');
            $table->string('status', 16)->default(\App\Enums\RegistryStatus::NOT_PAY)->comment('状态');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('registries');
    }
}
